﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using wlog.Model;

namespace wlog.Shell.Storage.Queue
{
    public class QueueUpdateCommand : QueueStorageCommand
    {
        public override void Setup(string[] args)
        {
            base.Setup(args);
            base.CreateTask(() => { RunCommand(); });
        }
        public OutputChannel RunCommand()
        {
            try
            {
                var QueueAPI = GetQueueAccount();
                var Queues = QueueAPI.ListQueues();
                if (Queues.Any())
                {
                    Results.WriteLine("Connected {0} Showing Queues", QueueAPI.BaseUri);
                    Results.WriteLine("\t{0:-30}\t{1}", "Name", "Uri");
                }
                foreach (var Queue in Queues)
                {
                    Results.WriteLine("\t{0:-30}\t{1}", Queue.Name, Queue.Uri);
                }
            }
            catch (Exception azureEx)
            {
                Results.WriteLine("Error ccreating Queue {0} ", azureEx.Message);
            }
            return Results;
        }

    }
}
